<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../../common/jsp/taglibs.jsp"%>
<!-- 
    Copyright (C)  2011  chen wei hua.
    Permission is granted to copy, distribute and/or modify this document
    under the terms of the GNU Free Documentation License, Version 2.0
    or any later version published by the Free Software Foundation;
    with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
    A copy of the license is included in the section entitled "GNU Free Documentation License".
 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>入库单一览</title>
<%@ include file="../../common/jsp/config.jsp"%>
<%@ include file="../../common/jsp/pageable.jsp"%>
<script type="text/javascript" src="common/js/calendar/WdatePicker.js" ></script>
<script type="text/javascript">
    function pageselectCallback(page_index, jq){
    	var oldPageIndex = $("#pageInfo_pageIndex").val();
        if (page_index != oldPageIndex) {
        	$("#pageInfo_pageIndex").val(page_index);
        	$("#inStoreVoucherList").submit();
        }
        return false;
    }

     function querySubmit() {
    	 $("#pageInfo_pageIndex").val("0");
    	 $("#inStoreVoucherList").submit();
    	 return false;
     }

  	function cleanSelectSku() {
		$("#skuDetailId").val("-1");
 		$("#materialsSKUName").html("");
 		$("#materialsName").val("");
	}
	
    function openSelectDialog() {
     	alertDialog(700, 500, "showSelectMaterialsDialog.action", 
     	function (result) {
     		var materials = result.materials;
     		if (materials) {
     			var fieldNames = "";
     			var skuId = result.skuId;
     		   	var skuConfig = materials.skuDetails;
     	 	   	for (var i in skuConfig) {
     	 	 	   	var config = skuConfig[i];
     	 	 	   	if (config.id == skuId) {
     	 	 	 	 	for (var j in config.fields) {
     	  	   				var field = config.fields[j];
     	  	   				fieldNames += field.customName + " ";
     	 	 	 	 	}
     	 	 	 	 	break;
     	 	 	   	}
     	 	   	}
     			$("#skuDetailId").val(skuId);
         		var str = ' ' + materials.rootCategory.name;
         		str += ' ' + materials.category.name;
         		str += ' ' + materials.name;
         		str += ' ' + materials.type;
         		str += ' ' + fieldNames;
         		$("#materialsSKUName").html(str);
         		$("#materialsName").val(str);
     		}
     	});
    }

</script>
</head>

<body>
    <div class="subnav" align="left">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td width="100%" align="left" height="31">&nbsp;<img src="common/images/title-pk.gif" border="0"  align="absmiddle"/>&nbsp;<span class="subnavtxt1">生产计划</span>
			&nbsp;<img src="common/images/leftico2.gif" border="0"  align="absmiddle"/>&nbsp;<span class="subnavtxt2">入库单一览</span></td>
		  </tr>
		</table>
      </div>
      <div class="btn-bottom" align="right"> 
		<input type="button" value="新建入库单" onclick='javascript:window.location.href="newInStoreVoucher.action"'  class="input1" />
	  </div>
   <div class="divborder">
      <s:form action="inStoreVoucherList">
        <s:hidden id="pageInfo_pageIndex" name="pageInfo.pageIndex" />
        <table width="100%" border="0" cellspacing="1" cellpadding="3">
          <tr>
            <td width="12%" align="right">送检日期</td>
            <td width="30%">
				<s:textfield name="condition.beginDate" 
					value="%{condition.beginDate==null?'':getText('global.date',{condition.beginDate})}"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="true" size="10"/>-
				<s:textfield name="condition.endDate" 
					value="%{condition.endDate==null?'':getText('global.date',{condition.endDate})}" 
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="true" size="10"/>
			</td>
            <td width="10%" align="right">状态</td>
            <td width="10%">
				<s:select list='#{"-1":"-请选择-", "1":"等待检验", "2":"等待入库", "10":"已经入库"}' name="condition.status" />
			</td>
            <td width="10%" align="right">检验单号</td>
            <td width="10%"><s:textfield name="condition.checkNo" size="20" /></td>
            <td align="right"><input name="button" type="button" class="input1" value="查 询" onclick="querySubmit()"/></td>
          </tr>
          <tr>
            <td align="right">单号</td>
            <td><s:textfield name="condition.voucherNo" size="20" /></td>
            <td align="right">生产批号</td>
            <td>
				<s:textfield name="condition.batchNo" size="20" />
			</td>
            <td align="right">原辅料</td>
    		<td colspan="2">
    			<input type="button" value="清空" onclick="cleanSelectSku()" />
    			<input type="button" value="请选择" onclick="openSelectDialog()" />
    		    <span id="materialsSKUName" ><s:property value="condition.materialsName" /></span>
    		    <s:hidden id="materialsName" name="condition.materialsName" />
    		    <s:hidden id="skuDetailId" name="condition.skuId" />
    		</td>
          </tr>
        </table>
      </s:form>
  </div >        
  <div class="ksglxx2">
        <table width="100%" cellpadding="0" cellspacing="1" border="0" class="ksglxx2a">
          <tr class="ksglxx2bg">
             <th width="10%" align="left">入库单号</th>
             <th width="20%" align="left">部门</th>
             <th width="10%" align="left">送检日期</th>
             <th width="10%" align="left">送检人</th>
             <th width="10%" align="left">状态</th>
             <th></th>
          </tr>
		<s:iterator value="voucherList" id="voucher" status="st">
           <s:if test="#st.Odd">
             <tr class="odd">
              <td><span class="detail">
                <a href='showInStoreVoucherInfo.action?voucherId=<s:property value="#voucher.id" />'><s:property value="#voucher.id" /></a>
              </span></td>
              <td><s:property value="#voucher.deptName" /></td>
              <td><s:date name="#voucher.createDate" format="yyyy-MM-dd"/></td>
              <td><s:property value="#voucher.person" /></td>
              <td><s:property value="#voucher.statusName" /></td>
              <td></td>
             </tr>
           </s:if>
           <s:else>
             <tr class="even">
              <td><span class="detail">
                <a href='showInStoreVoucherInfo.action?voucherId=<s:property value="#voucher.id" />'><s:property value="#voucher.id" /></a>
              </span></td>
              <td><s:property value="#voucher.deptName" /></td>
              <td><s:date name="#voucher.createDate" format="yyyy-MM-dd"/></td>
              <td><s:property value="#voucher.person" /></td>
              <td><s:property value="#voucher.statusName" /></td>
              <td></td>
             </tr>
           </s:else>
		</s:iterator>
      </table>
		<!--分页开始-->
		<div style="float:right;">
			<br style="clear:both;" /> 
			<div id="Pagination"></div> 
		</div>
		<!--分页结束-->
  </div>
</body>
</html>
